<template>
  <nav @click.stop>
    <TheUserPanel></TheUserPanel>
    <hr />
    <ul>
      <li
        v-for="item in navItems"
        :key="item.index"
        @click="activeIndex = item.index"
      >
        <a :class="{ active: item.index == activeIndex }" href="#">{{
          item.name
        }}</a>
      </li>
    </ul>
  </nav>
</template>

<script>
import TheUserPanel from "@/components/TheUserPanel.vue";
import { ref } from "vue";
export default {
  props: {
    navItems: Array,
  },
  components: {
    TheUserPanel,
  },
  setup() {
    const activeIndex = ref(0);

    return {
      activeIndex,
    };
  },
};
</script>

<style lang="scss" scoped>
nav {
  position: absolute;
  top: 0;
  right: -50%;
  background: rgb(252, 251, 251);
  width: 40%;
  height: 100%;
  ul {
    height: 100%;
    text-align: center;
    font-size: 1.75rem;
    list-style: none;
    padding: 0;
    margin: 0;
    li {
      cursor: pointer;
      margin-top: 20px;
      padding: 10px;
      a {
        color: inherit;
        text-decoration: none;
      }
    }
    li:hover {
      background: rgba(128, 128, 128, 0.075);
      font-weight: 550;
    }
  }
  .active {
    border-bottom: 2px solid gray;
  }
}
</style>